from common.unit import AndroidUI


# 未装箱列表操作
class UnboxedObject:

    def __init__(self):
        self.driver = AndroidUI.get_webdriver()

    # 未装箱按钮
    def unboxed_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/listUnpack")
        return element

    # 左上角返回按钮
    def back_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/iv_back")
        return element

    # // android.widget.TextView[ @ resource - id = 'com.bluephone:id/packbox']
    # 类型第几个
    def type(self, n):
        element = self.driver.find_element_by_xpath(
            f"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.ListView/android.widget.TextView[{n}]")
        # element=self.driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.ListView/android.widget.TextView[1]")

        # element=self.driver.find_element_by_android_uiautomator('new UiSelector().text("")')
        return element

    # 垃圾袋第几个
    def bag(self, n):
        element = self.driver.find_element_by_xpath(
            f"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.ListView/android.widget.LinearLayout[{n}]/android.widget.LinearLayout/android.widget.TextView")
        # element=self.driver.find_element_by_id("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.TextView")
        return element

    # 当前已选袋数
    # / hierarchy / android.widget.FrameLayout / android.widget.LinearLayout / android.widget.FrameLayout / android.widget.LinearLayout / android.widget.FrameLayout / android.widget.LinearLayout / android.widget.LinearLayout / \
    #   android.widget.LinearLayout[2] / android.widget.ListView / android.widget.LinearLayout[
    #       1] / android.widget.LinearLayout / android.widget.TextView

    def bags_number(self):
        element = self.driver.find_element_by_id("com.bluephone:id/packstatus")
        return element

    # 全选按钮
    def check_all_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/selall")
        return element

    # 装箱按钮
    def packing_box_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/packbox")
        return element



if __name__ == '__main__':
    pass
